package com.fs.aliyun.mns;

import com.aliyun.mns.client.CloudAccount;
import com.aliyun.mns.client.CloudQueue;
import com.aliyun.mns.client.MNSClient;
import com.aliyun.mns.model.Message;

/**
 * @author shuai.fang
 * @date：2017-06-30
 * @description：
 */
public class ConsumerDemo {
	public static void main(String[] args) {
		CloudAccount account = new CloudAccount("LTAId52CQ6kbSGlU", "rtfbvsLFpHIEV4Xi23Licpuz7ONVX3", "https://1370344375688957.mns.cn-beijing.aliyuncs.com/");
		MNSClient client = account.getMNSClient(); // 在程序中，CloudAccount以及MNSClient单例实现即可，多线程安全
		CloudQueue queue = client.getQueueRef("c-push-test");

		Thread t = new Thread(new Runnable() {
			@Override
			public void run() {
				System.out.println("正在运行....");
				while (true) {
					System.out.println("正在运行...");
					Message message = queue.popMessage(30);
					System.out.println("正在运行...");
					if (message != null) {
						System.out.println(message);
					}
				}
			}
		});
		t.start();
		while (!t.isInterrupted()) {}

	}
}
